/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projetlif13.model.puissance43D;

import projetlif13.model.Board3D;
import projetlif13.model.Move;
import projetlif13.model.Move3D;
import projetlif13.model.Player;

/**
 *
 * @author theo
 */
public class P43DBoard extends Board3D {

    public P43DBoard() {
        super(4, 4, 4);
        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                for (int z = 0; z < depth; z++) {
                    boardState[x][y][z] = -1;
                }
            }
        }
    }

    @Override
    public boolean makeMove(Move m, Player p) {
        Move3D move = (Move3D)m;
        if (boardState[move.x][move.y][move.z] == -1) {
            boardState[move.x][move.y][move.z] = p.getId();
            
            /*java.lang.ArrayIndexOutOfBoundsException: -1
            int tempZ = move.z;
            while (boardState[move.x][move.y][tempZ] == -1) {
                tempZ--;
                if (tempZ == 0) {
                    boardState[move.x][move.y][tempZ] = p.getId(); => 
                }
                boardState[move.x][move.y][tempZ] = p.getId();
            }
            * 
            */
            
            return true;
        } else {
            return false;
        }
    }
}
